package com.weilai.dao;

import com.weilai.domain.Background;
import com.weilai.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface BackgroundDao {
    //根据用户id查询背景
    @Select("SELECT id,user_id,url FROM background where user_id=#{userId}")
    public Background getByUserId(Integer userId);

    //更改背景
    @Update("update background set url=#{url} WHERE user_id=#{userId}")
    public void updateBackground(Background background);

    //注册背景
    @Insert("INSERT INTO background (user_id, url) VALUES (#{userId}, #{url});")
    public void insertBackground(int userId, String url);
}
